<template>
  <room
  v-if="dialogId"
    :session-id="sessionId" :is-document="isDocument" :parent-dialog-id="dialogId" :paf-id="props.paperId" :process-status="props.processStatus"
    @update-session-id="handleupdateSessionId" />
</template>
<script setup lang="ts">
import { computed, ref,watch,onBeforeMount } from 'vue';
import { useRoute } from 'vue-router';
defineOptions({
  'name': 'SessionRoom'
})
const props = defineProps(
  {
    isDocument: {
      type: Boolean,
      default: false
    }, id: {
      type: String,
      default: ''
    },
    processStatus: {
      type: Number,
      default: 3
    },
    paperId:{
      type: String,
      default: ''
    }
  }
)

console.log('id', props.id)
const route = useRoute()
onBeforeMount(()=>{
  // if(!route.params.id && !props.id){

  // }
  console.log('route', route.params.id, props.id)
})
const dialogId = computed(() => (props.id || route.params.id) ?? '')
watch(dialogId, (newVal, oldVal) => {
  sessionId.value = `${dialogId.value}_${Date.now()}`
})
const sessionId = ref(`${dialogId.value}_${Date.now()}`) //上下文的会话id
console.warn('route', dialogId, sessionId)
// console.log('pdfFile', pdfFile.value)
function handleupdateSessionId() {
  sessionId.value = `${dialogId.value}_${Date.now()}`
  console.log('handleupdateSessionId', sessionId.value)
}

</script>